<template>
  <div class="loader-contaner">
    <div class="loader"></div>
    <div class="loader-title">{{ title }}</div>
  </div>
</template>

<script>
export default {
  name: 'loading',
  data() {
    return {
      title: '正在载入...'
    }
  },
  methods: {
    setTitle(title) {
      this.title = title
    }
  }
}
</script>

<style lang="scss" scoped>
.loader-contaner {
  position: absolute;
  background-color: $color-background-mark;
  top:0;
  z-index: 99;
  width: 100%;
  height: 100%;
}
.loader-title{
  position: absolute;
  z-index: 99;
  top: calc(50% + 1.25em);
  left: 50%;
  font-size: $font-size-small;
  color: $color-text;
  transform: translateX(-50%);
  height: 2.5em;
  
}
.loader {
  position: absolute;
  z-index: 99;
  top: 0;
  width: 2.5em;
  height: 2.5em;
  transform: rotate(165deg);
}

.loader:before,
.loader:after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  width: 0.5em;
  height: 0.5em;
  border-radius: 0.25em;
  transform: translate(-50%, -50%);
}

.loader:before {
  animation: before8 2s infinite;
}

.loader:after {
  animation: after6 2s infinite;
}

@keyframes before8 {
  0% {
    width: 0.5em;
    box-shadow: 1em -0.5em rgba(225, 20, 98, 1), -1em 0.5em rgba(111, 202, 220, 1);
  }

  35% {
    width: 2.5em;
    box-shadow: 0 -0.5em rgba(225, 20, 98, 1), 0 0.5em rgba(111, 202, 220, 1);
  }

  70% {
    width: 0.5em;
    box-shadow: -1em -0.5em rgba(225, 20, 98, 1), 1em 0.5em rgba(111, 202, 220, 1);
  }

  100% {
    box-shadow: 1em -0.5em rgba(225, 20, 98, 1), -1em 0.5em rgba(111, 202, 220, 1);
  }
}

@keyframes after6 {
  0% {
    height: 0.5em;
    box-shadow: 0.5em 1em rgba(61, 184, 143, 1), -0.5em -1em rgba(233, 169, 32, 1);
  }

  35% {
    height: 2.5em;
    box-shadow: 0.5em 0 rgba(61, 184, 143, 1), -0.5em 0 rgba(233, 169, 32, 1);
  }

  70% {
    height: 0.5em;
    box-shadow: 0.5em -1em rgba(61, 184, 143, 1), -0.5em 1em rgba(233, 169, 32, 1);
  }

  100% {
    box-shadow: 0.5em 1em rgba(61, 184, 143, 1), -0.5em -1em rgba(233, 169, 32, 1);
  }
}

.loader {
  position: absolute;
  top: calc(50% - 1.25em);
  left: calc(50% - 1.25em);
}
</style>